#include "BlockQueue.hpp"
void *consumer(void *args)
{
    BlockQueue<int> *bq = static_cast<BlockQueue<int> *>(args);
 
    while (1)
    {
        sleep(5);
     
        bq->Pop();
        
       
    }
}
static int data = 1;
void *producer(void *args)
{
  
    BlockQueue<int> *bq = static_cast<BlockQueue<int> *>(args);
    while (1)
    {
        bq->EnQueue(data);
        printf("生产了一个数据data:%d\n", data++);
    }
}
int main()
{
    BlockQueue<int> *bq = new BlockQueue<int>();
    pthread_t c[4], p[3];
   

    pthread_create(p, nullptr, producer, bq);
    pthread_create(p + 1, nullptr, producer, bq);
    pthread_create(p + 2, nullptr, producer, bq);

    pthread_create(c, nullptr, consumer, bq);
    pthread_create(c + 1, nullptr, consumer, bq);
    pthread_create(c + 2, nullptr, consumer, bq);
    pthread_create(c + 3, nullptr, consumer, bq);

    pthread_join(p[0], nullptr);
    pthread_join(p[1], nullptr);
    pthread_join(p[2], nullptr);

    pthread_join(c[0], nullptr);
    pthread_join(c[1], nullptr);
    pthread_join(c[2], nullptr);
    pthread_join(c[3], nullptr);

    

    return 0;
}